import React, { PureComponent }from 'react';
import { Link, Route } from 'dva/router';
import { Menu, Dropdown, Icon } from 'antd';
import styles from './index.less'

import Holiday from './holiday';
import Food from './food';

const menu = (
  <Menu>
    <Menu.Item>
      <Link to='/holiday/apply'>Holiday</Link>
    </Menu.Item>
    <Menu.Item>
      <Link to='/food/book'>Food</Link>
    </Menu.Item>
  </Menu>
);

class PcIndex extends PureComponent {
  render() {
    const { location } = this.props;
    const type = location.pathname.split('/')[1];
    return(
      <div className={styles.wrapper}>
        <div className={styles.main}>
          <header>
            <h1 className={styles.logo}>日历</h1>
            <div className={styles.menu}>
              <Dropdown overlay={menu}>
                <span style={{paddingRight: '4px'}}>{type === 'holiday' ? 'Holiday' : 'Food'}<Icon style={{paddingLeft: '3px'}} type='down' /></span>
              </Dropdown>
            </div>
          </header>
          <main>
            <Route path='/holiday'  component={Holiday}/>
            <Route path='/food'  component={Food}/>
          </main>
        </div>
      </div>
    );
  }
}

export default PcIndex;
